package com;

import com.pojo.Employee;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import util.MybatisUtils;

public class EmployeeTest {
    @Test
    public void getEmployee() {
        SqlSession sqlSession = MybatisUtils.getSession();
        Employee employee = sqlSession.selectOne("com.mapper.EmployeeMapper.selectByPrimaryKey",(long)1);
        System.out.println(employee);
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void updateEmployeeTest() {
        SqlSession sqlSession = MybatisUtils.getSession();
        Employee employee = new Employee();
        employee.setId(5);
        employee.setName("杨帆");
        employee.setAge(100);
        employee.setPosition("总统");
        int e = sqlSession.update("com.mapper.EmployeeMapper.insert", employee);
        System.out.println(e);
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void deleteEmployeeTest() {
        SqlSession sqlSession = MybatisUtils.getSession();
        int d = sqlSession.delete("com.mapper.EmployeeMapper.deleteByPrimaryKey",1L);
        System.out.println(d);
        sqlSession.commit();
        sqlSession.close();
    }
}